import React, {useState} from "react";
import {Button, Form, Input, Modal} from "antd-mobile";
import {addPassenger} from "../../../utils/http/PassengerController";


const AddPassengerModal = (props: any) => {

  return (
      <Modal
          content={
              <Form
              onFinish={async (values: any)=>{
                  await addPassenger(values);
                  props.onFinish();
              }}
              footer={
                  <Button color={"primary"} type="submit" block>添加</Button>
              }
          >
              <Form.Item
                  name='name'
                  label='姓名'
                  rules={[{ required: true, message: '姓名不能为空' }]}
              >
                  <Input placeholder='请输入姓名' />
              </Form.Item>

              <Form.Item
                  name='identity'
                  label='身份证'
                  rules={[{ required: true, message: '身份证不能为空' }]}
              >
                  <Input placeholder='请输入身份证号码' />
              </Form.Item>
          </Form>
          }
          actions={[
              {
                  key: "cancel",
                  text: "取消",
                  danger: true,
              }
          ]}
          onAction={props.onFinish}
          visible={props.visible}
      />
  );
}

export default AddPassengerModal;